import request from "@/utils/request";
import type { getRolePermissionListResponse } from "./model/permissionModel";

enum Api {
  getRolePermissionListUrl = "/admin/acl/permission/toAssign",
  assignRolePermissionUrl = "/admin/acl/permission/doAssign",
  getPermissionListUrl = "/admin/acl/permission",
}


export const getRolePermissionListApi = (roleId: string) => {
  return request.get<any, getRolePermissionListResponse>(
    Api.getRolePermissionListUrl + `/${roleId}`
  );
};
//获取角色的权限列表
export const assignRolePermissionApi = (  roleId: string, permissionId: string[])=>{
return request.post<any,null>( 
   Api.assignRolePermissionUrl,{},
   {
    params:{
      roleId,
      permissionId: permissionId + "",
    }
   }
   )
}

export const getPermissionListApi = () => {
  return request.get<any, getRolePermissionListResponse>(
    Api.getPermissionListUrl 
  );
};